const app=require('express')();

//res-time
app.use((req,res,next)=>{
   res.startTime=Date.now();
   next();
});

//logger
app.use((req,res,next)=>{
    res.resStartTime=Date.now();
    next();
});

app.use((req,res)=>{
    console.log(`Logger: ${req.method} ${req.url} - ${Date.now()-res.resStartTime}ms`);
    res.setHeader('EXP-ResponseTime',Date.now()-(res.startTime)+'ms');
    res.end('Hello Express!');
});

app.listen(4000,()=>{
    console.log('Express port:4000----'+new Date().toLocaleTimeString());
});